package com.ddstation.crm.accountManage.service;

import com.ddstation.crm.accountManage.Entity.AccountManageEntity;
import com.ddstation.crm.accountManage.mapper.AccountManageMapper;
import com.ddstation.crm.accountManage.model.AccountManageModel;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.inject.Inject;
import java.util.List;

@Service @Lazy
public class AccountManageServiceImpl implements AccountManageService {

	@Inject private AccountManageMapper accountManageMapper;
	
	@Override
	@Transactional(readOnly=true)
	public List<AccountManageEntity> getAllAccount(AccountManageModel accountManageModel, Integer onePageCnt, Integer offset) {
		// TODO Auto-generated method stub
		return accountManageMapper.getAllAccount(accountManageModel.getInstitutionName(), accountManageModel.getName(), accountManageModel.getPhone(), onePageCnt, offset);
	}

	@Override
	@Transactional(readOnly=true)
	public int getAccountCnt(AccountManageModel accountManageModel) {
		// TODO Auto-generated method stub
		return accountManageMapper.getAccountCnt(accountManageModel.getInstitutionName(), accountManageModel.getName(), accountManageModel.getPhone());
	}
	
	@Override
	@Transactional(readOnly=true)
	public List<AccountManageEntity> getFreeAccount(String institutionId) {
		// TODO Auto-generated method stub
		return accountManageMapper.selectFreeAccount(institutionId);
	}

}
